package cn.i7baozh.consumer.service.fallback;

import cn.i7baozh.api.entities.CommonResult;
import cn.i7baozh.consumer.service.PaymentFeignService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author : baoqi.zhang
 * @date :   2022/4/8 14:37
 */
@Slf4j
@Component
public class PaymentFeignFallbackFactoryImpl implements FallbackFactory<PaymentFeignService> {
    @Override
    public PaymentFeignService create(Throwable throwable) {
        log.info("error !!!!!!!!!!!!!!!!!!!!");
        log.info("error:", throwable);
        return new PaymentFeignService(){
            @Override
            public String getPaymentInfo() {
                log.info("PaymentFeignFallbackFactoryImpl fallback");
                return "PaymentFeignFallbackFactoryImpl fallback";
            }

            @Override
            public CommonResult<String> abc() {
                log.info("PaymentFeignFallbackFactoryImpl fallback");
                return new CommonResult<>(200,"up");
            }

            @Override
            public String paymentTimeout() {
                log.info("PaymentFeignFallbackFactoryImpl fallback");
                return "timeout fallback";
            }
        };
    }
}
